#ifndef __BSP_TOOL_H__
#define __BSP_TOOL_H__


#define CRC_CHECK_TOOL    (0)
#define TIM_DELAY_TOOL    (0)
#define UART_PRINTF_TOOL  (1)

#if TIM_DELAY_TOOL
#define MyToolTimer (htim14)
#endif


#define UINT16_TO_UINT8(data8,data16) (data8[0]) = ((data16)>>8)&0xFF,\
                                      (data8[1]) = ((data16))&0xFF
                                      
#define UINT32_TO_UINT8(data8,data32) (data8[0]) = ((data16)>>24)&0xFF,\
                                      (data8[1]) = ((data16)>>16)&0xFF,\
                                      (data8[2]) = ((data16)>>8)&0xFF,\
                                      (data8[3]) = ((data16))&0xFF,\

                                      
#define PARMA_LIMIT(DATA,MAX,MIN) ((DATA)>(MAX)?0:(DATA)<(MIN)?0:1)

#define PARMA_LIMIT_BETWEEN(DATA,BASE,RANGE) PARMA_LIMIT((DATA),(BASE+RANGE),(BASE-RANGE))


#include "stdint.h"


uint8_t crc_8(uint8_t data[],uint8_t len);
int16_t complement_conversion_int16(int16_t complement_data);
void  delay_us(uint32_t time);
void tim_countUs_start(void);
uint32_t tim_countUs_get(void);
void tim_countUs_stop(void);

#endif
